# -*- coding:utf8 -*-
# __author__ = "zhangying"
# __date__ = "2019/2/19 10:42"

#handle层 操作层 操作元素page

from page.login_page import Login_Page


class LoginhHandle:
    def __init__(self,i):
        self.login_page = Login_Page(i)
        #操作登陆页面的元素

    def send_username(self,user):
        '''
        输入用户名
        :param user:
        :return:
        '''
        self.login_page.get_usernamer_element().send_keys(user)

    def send_password(self,password):
        '''
        输入密码
        :param password:
        :return:
        '''
        self.login_page.get_password_element().send_keys(password)

    def click_login(self):
        '''
        点击登陆按钮
        :return:
        '''
        self.login_page.get_login_button_element().click()

    def click_forget(self):
        '''
        点击忘记密码按钮
        :return:
        '''
        self.login_page.get_forget_password_element().click()

    def click_register(self):
        '''
        点击注册按钮
        :return:
        '''
        self.login_page.get_register_element().click()

    def get_fail_tost(self,message):
        '''
        获取tost,根据返回数据进行反数据
        :param message:
        :return:
        '''
        tost_element = self.login_page.get_tost_element(message)
        if tost_element:
            return True
        else:
            return False
